package com.lee9213.conference.track.management.entity;

import com.lee9213.conference.track.management.constant.Constant;
import com.lee9213.conference.track.management.enums.TalkTypeEnum;
import com.lee9213.conference.track.management.util.StringUtil;

import java.io.Serializable;
import java.time.LocalTime;

/**
 * 会话实体
 *
 * @author lee9213@163.com
 * @version 1.0
 * @date 2018-07-11 11:48
 */
public class TalkEntity implements Serializable {

    /**
     * 会话标题
     */
    private String title;

    /**
     * 会话类型
     */
    private String talkType;

    /**
     * 会话时长
     */
    private int minutes;

    /**
     * 会话开始时间
     */
    private String startTime;

    public TalkEntity() {
    }

    public TalkEntity(String title, String startTime) {
        this.title = title;
        this.startTime = startTime;
    }

    public TalkEntity(String title, int minutes, String startTime) {
        this.title = title;
        this.minutes = minutes;
        this.startTime = startTime;
    }

    public TalkEntity(String title, String talkType, int minutes) {
        this.title = title;
        this.talkType = talkType;
        this.minutes = minutes;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTalkType() {
        return talkType;
    }

    public void setTalkType(String talkType) {
        this.talkType = talkType;
    }

    public int getMinutes() {
        return minutes;
    }

    public void setMinutes(int minutes) {
        this.minutes = minutes;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        if (!StringUtil.isNullOrEmpty(this.startTime)) {
            builder.append(LocalTime.parse(this.startTime).format(Constant.DATE_TIME_FORMATTER));
        }
        builder.append(" ");
        builder.append(this.title);
        builder.append(" ");
        if (this.minutes > 0 && TalkTypeEnum.MINUTES.getName().equalsIgnoreCase(this.talkType)) {
            builder.append(this.minutes);
        }
        if (!StringUtil.isNullOrEmpty(this.talkType)) {
            builder.append(this.talkType);
        }
        return builder.toString();
    }
}
